<?php
    require_once('../code/global.php');
    require_once('/code/Admin.php');
    require_once('/code/Product.php');
    $admin=new Admin();
    $admin->loginCheck(1);
    if(!isset($_GET['iid'])) {header('Location:items.php');exit;}
    $iid=intval($_GET['iid']);
    $cid=intval($_GET['cid']);
    $product=new Product();
    $img=$product->getImage($iid);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>PhotoFromThe1st 后台管理系统</title>
        <link rel="stylesheet" href="/styles/admin.css" type="text/css" media="all">
        <script type="text/javascript" src="/script/jquery-1.6.1.min.js"></script>
        <script type="text/javascript" src="/script/script.js"></script>
        <script type="text/javascript">
            window.parent.scroll(0,0);
        </script>
    </head>
    <body>
        <div class="msgBox">编辑照片信息 <a href="editItem.php?pid=<?php echo $img['product_id']; ?>&cid=<?php echo $cid; ?>">返回</a></div>
        <table border="0" cellspacing="0" cellpadding="0" class="detailTable">
            <tr class="thumbTr"><td colspan="2"><img src="<?php echo $img['img_url']; ?>"><?php if($img['is_cover']) echo '<div class="btnDiv"><div>Cover Image</div></div>'; ?></td></tr>
            <form name="editGalleryImageInfo" action="exec.php" method="post">
            <input type="hidden" name="action" value="editGalleryImageInfo">
            <input type="hidden" name="img_id" value="<?php echo $img['img_id']; ?>">
            <input type="hidden" name="category_id" value="<?php echo $cid; ?>">
            <input type="hidden" name="product_id" value="<?php echo $img['product_id']; ?>">
            <tr><td>Image Caption:</td><td><input type="text" name="img_caption" maxlength="64" class="inputBox" value="<?php echo $img['img_caption']; ?>"></td></tr>
            <tr><td>Description:</td><td><textarea name="img_descript" class="smallTxt"><?php echo $img['img_descript']; ?></textarea></td></tr>
            <tr><td>Created:</td><td><?php echo $img['create_time']?></td></tr>
            <tr><td>Modified:</td><td><?php echo $img['modify_time']?></td></tr>
            <tr class="btnTr header"><td colspan="2"><input class="btnLnk" type="submit" name="save" value="Save"><input class="btnLnk" type="reset" name="reset" value="Reset"><input class="btnLnk" type="button" name="cancel" value="Cancel" onclick="location.href='editItem.php?pid=<?php echo $img['product_id']; ?>&cid=<?php echo $cid; ?>'"></td></tr>
            </form>
            <form name="deleteGalleryImage" action="exec.php" method="post"><input type="hidden" name="action" value="deleteGalleryImage"><input type="hidden" name="img_id" value="<?php echo $img['img_id']; ?>"><input type="hidden" name="category_id" value="<?php echo $cid; ?>"><input type="hidden" name="product_id" value="<?php echo $img['product_id']; ?>">
            <tr class="btnTr header"><td colspan="2"><input class="btnLnk btnDel" type="submit" name="delete" value="Delete"<?php echo $img['is_cover'] | $product->countGalleryImages($img['product_id'])<2?' disabled':''; ?>></td></tr>
            </form>
        </table>
    </body>
</html>